import Vue from 'vue';
import VeeValidate, { Validator } from 'vee-validate';

import messages from "./zh_CN"

Validator.updateDictionary({
  zh_CN: {
    messages
  }
});

const config = {
  errorBagName: 'errors', // change if property conflicts.
  delay: 0,
  locale: 'zh_CN',
  messages: null,
  strict: true
};


Vue.use(VeeValidate,config);


Validator.extend('phone', {
    messages: {
      zh_CN:field =>  '请输入正确的手机号',
  },
  validate: value => {
  return value.length == 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/.test(value)
}
});

Validator.extend('code', {
    messages: {
      zh_CN:field => '请输入正确格式的验证码',
  },
  validate: value => {
  return  /^\d{6}$/.test(value)
}
});

Validator.extend('password', {
    messages: {
      zh_CN:field =>  '请输入6-16位不含特殊字符',
  },
  validate: value => {
  return  /^[a-zA-Z0-9_]{6,16}$/.test(value)
}
});
